<template>
  <div class="bottom">
    <div class="left-block">
      <div class="image-box"><img :src="curMusic.img_url" alt=""></div>
      <div class="name-box">
        <p class="song-name">{{curMusic.name}}</p>
        <p class="songer-name">{{curMusic.singer}}</p>
      </div>
    </div>
    <div class="right-block">
      <div class="menu-btn" @click="showPlayingMusic">
        <i class="icon-list-music"></i>
      </div>
      <div class="control-btn" @click="togglePlay" >
        <i :class="[isPlaying?'icon-pause' : 'icon-play',{isPlaying:isPlaying}]"  ></i>
      </div>
    </div>
  </div>
</template>

<script>
  import store from '../../store';
  export default {
    name: "bottom-bar",
    computed: {
      isPlaying() {
        return store.getters.getPlay;
      },
      curMusic(){
        return store.getters.getCurMusic;
      }
    },
    methods:{
      togglePlay(){
        store.commit('togglePlay');
      },
      showPlayingMusic(){
        store.dispatch('set_playingShow',true);
      }
    }
  }
</script>

<style scoped lang="scss">
  @import '../../../static/font-icon/style.css';
  @import '../../../static/style/public';

  //图片的边距
  $img-margin: 4px;
  $icon-size: 24px;
  .isPlaying{
    color:$primaryColor !important;
  }
  .bottom {
    position: fixed;
    bottom: 0px;
    left: 0px;
    width: 100%;
    height: $bottomHeight;
    background-color: white;
    border-top: 1px solid lightgrey;

    .left-block {
      display: flex;
      justify-content: flex-start;
      align-items: flex-end;
      position: absolute;
      left: 0px;
      top: 0px;
      width: 50%;
      height: $bottomHeight;
      .image-box {
        @include flex-center;
        width: $bottomHeight;
        height: $bottomHeight;
        img {
          display: inline-block;
          width: $bottomHeight -  $img-margin;
          height: $bottomHeight - $img-margin;
          background-color: #e74c3c;
        }
      }

      .name-box {
        p {
          margin: 0px;
          width: 100%;
          padding: 3px 4px;
          display: block;
          text-overflow: ellipsis;
          white-space: nowrap;
          font-weight: 500
        }
        .song-name {
          font-size: 14px;
          color: #333;
        }
        .songer-name {
          font-size: 10px;
          color: #aaa;
        }
      }
    }

    .right-block {
      display: flex;
      flex-direction: row-reverse;
      align-items: center;
      position:absolute;
      top:0px;
      right:0px;
      height:$bottomHeight;
      width:50%;
      .control-btn, .menu-btn {
        width: $bottomHeight;
        height: $bottomHeight;
        text-align: center;
        &:hover {
          border-color: $primaryColor;
          cursor: pointer;
          i{
            color:$primaryColor;
          }
        }
        &:active{
          background-color: #f1f1f1;
        }
        i {
          font-size: $icon-size;
          line-height: $bottomHeight;
          color: lightgrey;
        }
      }
      .control-btn{
        width:$bottomHeight - 20px;
        height:$bottomHeight - 20px;
        border:2px solid lightgrey;
        border-radius: 50px;
        & i{
          font-size:$icon-size - 5px;
          line-height:$bottomHeight - 20px;
        }
      }
    }
  }
</style>
